from django.contrib import admin
from django.utils.safestring import mark_safe

from . import models


# 留言
class MessageManager(admin.ModelAdmin):
    list_display = ['get_user', 'user_message', 'admin_message', 'create_time', 'update_time']

    # 获取用户名称
    def get_user(self, obj):
        return [obj.user.username]
    get_user.short_description = mark_safe('<div style="color:#409eff">用户<div>')

admin.site.register(models.Message, MessageManager)
